<?php

namespace App\Http\Controllers\CmsApi;

use Illuminate\Http\Request;
use App\Lib\Response;
use App\Http\Controllers\BaseController;
use App\Http\Model\Hint;
use App\Http\Services\ComeBackServices;

class InnerComeBackController extends BaseController
{
    protected $comeBackService;

    public function __construct()
    {
       $this->comeBackService = new ComeBackServices();
    }

    //后台-新增配置
    public function addComeBackConfig(Request $request){
        $res = $this->comeBackService->addComeBackConfig($request->all());
        if($res['code'] != Hint::SUCCESS){
            Response::returnResult(Hint::ERR_NORMAL,[],$res['msg']);
        }
        Response::returnResult(Hint::SUCCESS);
    }  
    
    //后台-编辑配置
    public function editComeBackConfig(Request $request){
        $res = $this->comeBackService->editComeBackConfig($request->all());
        if($res['code'] != Hint::SUCCESS){
            Response::returnResult(Hint::ERR_NORMAL,[],$res['msg']);
        }
        Response::returnResult(Hint::SUCCESS);
    }

    //后台-删除配置
    public function delComeBackConfig(Request $request){
        $res = $this->comeBackService->delComeBackConfig($request->all());
        if($res['code'] != Hint::SUCCESS){
            Response::returnResult(Hint::ERR_NORMAL,[],$res['msg']);
        }
        Response::returnResult(Hint::SUCCESS);
    }

    //后台-新增签到配置
    public function addSiginConfig(Request $request){
        $res = $this->comeBackService->addSiginConfig($request->all());
        if($res['code'] != Hint::SUCCESS){
            Response::returnResult(Hint::ERR_NORMAL,[],$res['msg']);
        }
        Response::returnResult(Hint::SUCCESS);
    }

    //后台-编辑签到配置
    public function editSiginConfig(Request $request){
        $res = $this->comeBackService->editSiginConfig($request->all());
        if($res['code'] != Hint::SUCCESS){
            Response::returnResult(Hint::ERR_NORMAL,[],$res['msg']);
        }
        Response::returnResult(Hint::SUCCESS);
    }

    //后台-删除签到配置
    public function delSiginConfig(Request $request){
        $res = $this->comeBackService->delSiginConfig($request->all());
        if($res['code'] != Hint::SUCCESS){
            Response::returnResult(Hint::ERR_NORMAL,[],$res['msg']);
        }
        Response::returnResult(Hint::SUCCESS);
    }

    //后台-添加每日任务
    public function addDayTask(Request $request){
        $res = $this->comeBackService->addDayTask($request->all());
        if($res['code'] != Hint::SUCCESS){
            Response::returnResult(Hint::ERR_NORMAL,[],$res['msg']);
        }
        Response::returnResult(Hint::SUCCESS);
    }

    //后台-编辑每日任务
    public function editDayTask(Request $request){
        $res = $this->comeBackService->editDayTask($request->all());
        if($res['code'] != Hint::SUCCESS){
            Response::returnResult(Hint::ERR_NORMAL,[],$res['msg']);
        }
        Response::returnResult(Hint::SUCCESS);
    }

    //后台-删除每日任务
    public function delDayTask(Request $request){
        $res = $this->comeBackService->delTaskConfig($request->all());
        if($res['code'] != Hint::SUCCESS){
            Response::returnResult(Hint::ERR_NORMAL,[],$res['msg']);
        }
        Response::returnResult(Hint::SUCCESS);
    }
}